package cn.bonoon.kernel.web.components;

import cn.bonoon.kernel.descriptors.UIPropertyAccessor;
import cn.bonoon.kernel.web.html.UIPropertyBuilder;
import cn.bonoon.kernel.web.html.form.ComponentPropertyParser;

public class InputComponent extends AbstractInputComponent {

	public InputComponent(ComponentPropertyParser property, UIPropertyAccessor accessor) {
		super(property, accessor);
	}
	
	@Override
	protected void initInputAttribute(StringBuilder html, StringBuilder settings, UIPropertyBuilder builder) {
		super.initInputAttribute(html, settings, builder);
		/*
		 * 这里需要对值进行转义处理
		 */
		html.append(" value='${__escape.value($").append(builder.getBindedName());
		html.append('.').append(componentName).append(")}'");
	}

	@Override
	protected void parser(UIPropertyBuilder builder) {
		input(builder);
		if(validate){
			builder.getInitBlock().append("jQuery('#").append(componentId).append("').bupvalidator();");
		}
	}
}
